home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pasnews.zip / TESTIT.PAS < prev    next >
Pascal/Delphi Source File  |  1990-05-17  |  1KB  |  70 lines

  1. Program TestLL;
  2.  
  3. { This is a short little program I wrote to test the Linked List.
  4.   The documentation is pretty scarce. At this point you should
  5.   understand enough about how it works.                           }
  6.  
  7. uses LinkList, CRT;
  8.  
  9. var
  10.   AList1,
  11.   AList2 : Data_Ptr;  { Our Two Lists. }
  12.   ANum   : DataType;
  13.   Count  : integer;
  14.  
  15.  
  16. begin
  17.   clrscr;
  18.  
  19.   Init_List(AList1);
  20.  
  21.  
  22.   { First test is a stack. First we insert at the beginning,
  23.     and then we'll use the Pop_First to get it back.          }
  24.  
  25.   randomize;
  26.   for Count := 1 to 20 do
  27.     begin
  28.       ANum := Random(40);
  29.       gotoxy(5,Count);
  30.       write(ANum);
  31.       Insert_Begin(AList1, ANum);
  32.     end;
  33.  
  34.  
  35.   for Count := 1 to 20 do
  36.     begin
  37.       gotoxy(45, Count);
  38.       Write(Pop_First(AList1));
  39.     end;
  40.   gotoxy(15,23);
  41.   write('--> Hit the ENTER Key to Continue <--');
  42.   readln;
  43.   clrscr;
  44.  
  45.   Init_List(AList2);
  46.  
  47.   { The second test is a little different. We are going to insert
  48.     in order and then retreive from the rear, so we should be able
  49.     to see our list in reverse order.                              }
  50.  
  51.   randomize;
  52.   for Count := 1 to 20 do
  53.     begin
  54.       ANum := Random(40);
  55.       gotoxy(5,Count);
  56.       write(ANum);
  57.       Insert_In_Order(AList2, ANum);
  58.     end;
  59.  
  60.   for Count := 1 to 20 do
  61.     begin
  62.       gotoxy(45, Count);
  63.       Write(Pop_Last(AList2));
  64.     end;
  65.   gotoxy(15,23);
  66.   write('--> Hit the ENTER Key to Continue <--');
  67.   readln;
  68.  
  69. end.
  70.